<template>
  <div>
    <el-form label-width="120px" label-position="left" :model="searchForm">
      <el-row>
        <el-col :span="8">
          <el-form-item label="状态">
            <el-select v-model="searchForm.status">
              <el-option label="全部" :value="''"></el-option>
              <el-option label="等待房东回复" :value="1"></el-option>
              <el-option label="等待租客回复" :value="2"></el-option>
              <el-option label="房东拒绝" :value="3"></el-option>
              <el-option label="租客拒绝" :value="4"></el-option>
              <el-option label="发起合约" :value="5"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建时间">
            <el-date-picker
              v-model="searchForm.createTime"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-button @click="onSearch" type="primary">查 询</el-button>
          <el-button @click="reset()">重 置</el-button>
        </el-col>
      </el-row>
    </el-form>
    <hr />
    <page-table
      :data="tableData"
      :total="count"
      :page="pageIndex"
      :pageSize="pageSize"
      ref="pageTable"
      showIndex
      @currentChange="currentChange"
      @sizeChange="sizeChange"
      :loading="loading"
    >
      <el-table-column
        show-overflow-tooltip
        prop="userNickName"
        label="发起人"
      ></el-table-column>
      <el-table-column show-overflow-tooltip label="房东">
        <template slot-scope="{ row }">
          {{ row.houseUser.nickName }}
        </template>
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="rent"
        label="租金"
      ></el-table-column>
      <el-table-column show-overflow-tooltip label="开始时间">
        <template slot-scope="{ row }">
          {{ row.startTime | timeFilter }}
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="结束时间">
        <template slot-scope="{ row }">
          {{ row.endTime | timeFilter }}
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="创建时间">
        <template slot-scope="{ row }">
          {{ row.createdAt | timeFilter }}
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="状态">
        <template slot-scope="{ row }">
          {{ row.status | askStatusFilter }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <el-button type="text" @click="toDetail(row.id)">详情</el-button>
          <el-button
            type="text"
            v-if="row.status === 1"
            @click="toEdit(row.id)"
            >回复</el-button
          >
        </template>
      </el-table-column>
    </page-table>
    <post-dialog @cancel="cancel" :dialogVisible="dialogVisible" :opId="opId" />
    <detail-dialog
      @cancel="cancel1"
      :dialogVisible="dialogVisible1"
      :opId="opId"
    />
  </div>
</template>

<script>
import getAreaList from "../../../mixins/getAreaList";
import initData from "../../../mixins/initData";
import DetailDialog from "../components/detailDialog";
import PostDialog from "../components/postDialog";

export default {
  components: { DetailDialog, PostDialog },
  name: "askYoursManage",
  mixins: [getAreaList, initData],
  data() {
    return {
      getUrl: "/api/ask/ask/yours",
      searchForm: {
        status: "",
        createTime: ""
      }
    };
  }
};
</script>

<style scoped></style>
